<template>
  <div class="newslist">
    <!-- <van-card v-for="item in newslist" :key="item.id" :title="item.title" :thumb="imageURL">
      <div slot="footer">
        <span class="ctime">{{item.add_time}}</span>
        <span class="click">{{item.click}}</span>
      </div>
    </van-card> -->

      <router-link v-for="item in newslist" :key="item.id" :to="'/NewList/Comments/'+item.id" >
      <van-card :title="item.title" :thumb="imageURL">
        <div slot="footer">
          <span class="ctime">{{item.add_time}}</span>
          <span class="click">{{item.click}}</span>
        </div>
      </van-card>
    </router-link> 

    <!-- <router-link v-for="(item,index) in newslist" :key="index" :to="'/home/detail/'+item.id">
      <van-card :title="item.title" :desc="item.content" :num="item.click" :thumb="imageURL">
        <div slot="footer">
          <span>{{item.add_time}}</span>
          <van-button size="mini">查看</van-button>
        </div>
      </van-card>
    </router-link>  -->

  </div>

</template>

<script>
export default {
  data: () => ({
    newslist: [],
    imageURL:
      "http://img02.tooopen.com/images/20151125/tooopen_sy_149443338326.jpg"
  }),
  created() {
    this.getNewsList();
  },
  methods: {
    // getNewsList() {
    //   this.$http.get("api/getnewslist").then(result => {
    //     console.log(result);
    //     const { status, message } = result.body;
    //     if (status === 0) {
    //       this.newlist = message;
    //     } else {
    //       console.log("请求新闻页面数据失败");
    //     }
    //   });
    // }
    getNewsList() {
      this.$http.get("api/getnewslist").then(result => {
        console.log(result.body);
        // const {status,message} = result.body;
        const status = result.body.status;
        const message = result.body.message;
        if (status === 0) {
          this.newslist = message;
        } else {
          console.log("请求页面失败");
        }
      });
    }
  }
};
</script>

<style>
van-card:not(:first-child) {
  margin-top: 10px;
}
.van-card,
.van-card__thumb,
.van-card__row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}
.van-card {
  color: #333;
  height: 100px;
  font-size: 16px;
  background: #fafafa;
  position: relative;
  box-sizing: border-box;
  padding: 5px 15px 5px 115px;
}
</style>